from selenium import webdriver
from selenium.webdriver.common.by import By

wd = webdriver.Chrome()
url = "https://www.12306.cn/"
wd.get(url)
wd.find_element(By.LINK_TEXT, "注册").click()
wd.find_element(By.ID, 'userName').send_keys("a123456")
wd.find_element(By.NAME, "userDTO.password").send_keys("cxr19150979228")
wd.find_element(By.ID, "confirmPassWord").send_keys("cxr19150979228")

a = wd.find_elements(By.TAG_NAME,'input')
for i in a:
    if i.get_attribute("name")=="loginUserDTO.name":
        break
i.send_keys("陈祥润")
for i1 in a:
    if i1.get_attribute("name")=="loginUserDTO.id_no":
        break
i1.send_keys("51132220030301287X")
for i2 in a:
    if i2.get_attribute("name")=="userDTO.email":
        break
i2.send_keys("3033087651@qq.com")
for i3 in a:
    if i3.get_attribute("name")=="userDTO.mobile_no":
        break
i3.send_keys("19150979228")